json-comments-rs
json_comments
is a library to strip out comments from JSON-like text. By processing text
through a [StripComments
] adapter first, it is possible to use a standard JSON parser (such
as serde_json with quasi-json input that contains
comments.
In fact, this code makes few assumptions about the input and could probably be used to strip comments out of other types of code as well, provided that strings use double quotes and backslashes are used for escapes in strings.
The following types of comments are supported:
- C style block comments (
/* ... */
) - C style line comments (
// ...
) - Shell style line comments (
# ...
)
Example using serde_json
use ;
use StripComments;